package me.study.concurrent;

import java.io.IOException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;

import org.junit.Test;

/**
 *  LinkedBlockingQueue链阻塞队列
 *  @author GJ-Alan
 */
public class LinkedBlockingQueueTest {
	@Test
	public void test() throws InterruptedException, IOException {
		
		BlockingQueue<String> linkedQueue=new LinkedBlockingDeque<String>();
		linkedQueue.add("aaa");
		linkedQueue.add("bbb");
		linkedQueue.put("cc");
		System.out.println(linkedQueue.take());
		System.out.println(linkedQueue.poll());
		System.out.println(linkedQueue.peek());
		System.out.println("设置超时时间为3s");
		System.out.println("测试过期"+linkedQueue.poll(3,TimeUnit.SECONDS));
		System.out.println("3s过期");
	}
}
